< previous page page_296 next page >

Page 296
   For x = 0 To List1.ListCount
      newline = newline & List1.List(x) & vbCrLf
   Next x
   Clipboard.Clear
   Clipboard.SetText newline
End Sub
The results shown in the listbox are as follows:
Integer: 05 00
Long: 05 00 00 00
Single (Float): 00 00 A0 40
Double: 00 00 00 00 00 00 14 40
Currency: 50 C3 00 00 00 00 00 00
Byte: 05
Variant: 02 00 00 00 00 00 00 00 05 00 00 00 00 00 00 00
String: E4 05 18 00
3
The most important thing to notice can be seen with the Integer and Long variables. When you assign 5 to a 16-bit integer, the value in binary will be 0000000000000101 (or &H0005). Remember the number scheme we used originally, in which the rightmost bit was Bit #0? The rightmost bit (or digit) is called the least significant bit (or nibble) because it represents the smallest change to the value of the overall number. As you can see in the memory display for these variables, the least significant digit appears at the lowest address in memory (the bytes in memory are displayed starting from the lowest memory address). Thus, the number &H0005 will appear in a memory dump as 05 00. It looks like the bytes are swapped! They aren't reallyit's just how you arrange things on paper.
The Float, Double, and Currency values don't seem to make much sense. That's because they don't. The internal format used by these data types is something even advanced programmers rarely worry about.
The Variant type is another one you'll rarely worry about. The 02 at the beginning indicates that the variable contains a signed integer. A variant can contain many types of variables, so it needs to store the type internally. The 05 appears later in the data area of the variant.
Don't worry about the stringthat is definitely a subject for later.
7017a6ead0e3c4111b47a554df321e9f.gif 7017a6ead0e3c4111b47a554df321e9f.gif
3 This value will almost certainly differ on your machine.

 
< previous page page_296 next page >